﻿#include "server.h"
#include <iostream>
#include <string>
#include "./util/loadDllUtil.h"
#include "./util/loadLibUtil.h"
using namespace std;

server::server()
{
}

int server::run()
{
	cout << "Hello World!\n" << endl;
#if defined(SYS_WINDOWS)
	string dllDir = "./dll/share.dll";
#endif
#if defined(SYS_LINUX)
	string dllDir = "./dll/share.so";
#endif

	bool loaddll = false;
	if (loaddll)
	{
		HMODULE_HANDLE h = loadDllUtil::gdl_Open(dllDir.c_str());
		typedef int(*pFun)(int a, int b);
		pFun p = (pFun)loadDllUtil::gdl_GetProc(h, "common_dll");
		int result = p(3, 5);
		//使用宽字符+字符串前加上L，避免linux中出现乱码
		cout << "调用动态库方法:" << result << endl;
		loadDllUtil::gdl_Close(h);

		//静态库调用
		loadLibUtil::load();
	}

#if defined(SYS_WINDOWS)
	system("pause");
#endif
	return 0;
}
